package org.kwin.tomcat.servlet.http;

/**
 * @author : wangkai
 * @version V1.0
 * @Package org.kwin.tomcat.servlet.http
 * @Description:
 * @date 2021年10月12日 9:26
 **/
public abstract class HttpServlet {
    
    private static final String METHOD_DELETE = "DELETE";
    private static final String METHOD_HEAD = "HEAD";
    private static final String METHOD_GET = "GET";
    private static final String METHOD_OPTIONS = "OPTIONS";
    private static final String METHOD_POST = "POST";
    private static final String METHOD_PUT = "PUT";
    private static final String METHOD_TRACE = "TRACE";
    
    public void service(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        if(METHOD_GET.equalsIgnoreCase(req.getMethod())) {
            doGet(req, resp);
        } else {
            doPost(req, resp);
        }
    }
    
    public abstract void doGet(HttpServletRequest req, HttpServletResponse resp) throws Exception;
    
    public abstract void doPost(HttpServletRequest req, HttpServletResponse resp) throws Exception;
    
}
